package com.isman.placeslist;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TabHost;
import android.widget.TextView;

public class PagePlace extends TabActivity {	
	public static final String LOCATION_ID = "locationId";
  
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.page_place);
        mLocationId = getIntent().getExtras().getLong(LOCATION_ID);
        Log.e("PlacePlace",mLocationId+"");
		mLoad();
	}

	protected void mLoad() {
		mAddLeft("Detail", TabPlaceDetail.class);		
		mAddRight("Board", TabPlaceBoard.class) ;
//		mAddRight("Gallery", TabPlaceGallery.class);
	}
	protected void mAddLeft(String labelId, Class<?> c){
		TabHost tabHost = getTabHost();
		Intent intent = new Intent(this, c);
		intent.putExtra(LOCATION_ID, mLocationId);
		TabHost.TabSpec spec = tabHost.newTabSpec("tab" + labelId);	
		
		View tabIndicator = LayoutInflater.from(this).inflate(R.layout.inc_tab_indicator, getTabWidget(), false);
		tabIndicator.setBackgroundResource(R.drawable.bg_tab_indicator_left);
		TextView title = (TextView)tabIndicator.findViewById(R.id.title);
		title.setText(labelId);
		
		spec.setIndicator(tabIndicator);
		spec.setContent(intent);
		tabHost.addTab(spec);
	}	
	protected void mAddCenter(String labelId, Class<?> c){
		TabHost tabHost = getTabHost();
		Intent intent = new Intent(this, c);
		intent.putExtra(LOCATION_ID, mLocationId);
		TabHost.TabSpec spec = tabHost.newTabSpec("tab" + labelId);	
		
		View tabIndicator = LayoutInflater.from(this).inflate(R.layout.inc_tab_indicator, getTabWidget(), false);
		tabIndicator.setBackgroundResource(R.drawable.bg_tab_indicator_center);
		TextView title = (TextView)tabIndicator.findViewById(R.id.title);
		title.setText(labelId);
		
		spec.setIndicator(tabIndicator);
		spec.setContent(intent);
		tabHost.addTab(spec);
	}
	protected void mAddRight(String labelId, Class<?> c){
		TabHost tabHost = getTabHost();
		Intent intent = new Intent(this, c);
		intent.putExtra(LOCATION_ID, mLocationId);
		TabHost.TabSpec spec = tabHost.newTabSpec("tab" + labelId);	
		
		View tabIndicator = LayoutInflater.from(this).inflate(R.layout.inc_tab_indicator, getTabWidget(), false);
		tabIndicator.setBackgroundResource(R.drawable.bg_tab_indicator_right);
		TextView title = (TextView)tabIndicator.findViewById(R.id.title);
		title.setText(labelId);
		
		spec.setIndicator(tabIndicator);
		spec.setContent(intent);
		tabHost.addTab(spec);
	}
    private long mLocationId;
}
